package com.kede.system.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.annotation.*;
import javax.persistence.*;
import javax.validation.constraints.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.annotations.*;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @description /
* @author Pr.li
* @date 2023-04-18
**/
@Entity
@Data
@Table(name="sys_virtual")
@TableName(value="sys_virtual")
public class SysVirtual implements Serializable {
        /**
        * 虚拟的最小值
        */
    @TableField(value = "`min`")
    @Column(name = "`min`",nullable = false)
    @NotNull
    private Integer min;
        /**
        * 虚拟的最大值
        */
    @TableField(value = "`max`")
    @Column(name = "`max`",nullable = false)
    @NotNull
    private Integer max;
        /**
        * 执行频率  Cron
        */
    @TableField(value = "`cron`")
    @Column(name = "`cron`",nullable = false)
    @NotBlank
    private String cron;
        /**
        * 虚拟标识说明 牵记不可改
        */
    @Id
    @TableId(value = "`name`")
    @TableField(value = "`name`")
    @Column(name = "`name`")
    private String name;
        /**
        * 创建时间
        */
    @TableField(value = "`create_time`")
    @Column(name = "`create_time`",nullable = false)
    @NotNull
    @CreationTimestamp
    private Timestamp createTime;
        /**
        * 更新时间
        */
    @TableField(value = "`update_time`")
    @Column(name = "`update_time`",nullable = false)
    @NotNull
    @UpdateTimestamp
    private Timestamp updateTime;
        /**
        * 存放虚拟值
        */
    @TableField(value = "`value`")
    @Column(name = "`value`",nullable = false)
    @NotNull
    private Long value;

    public void copy(SysVirtual source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
